//
//  RCTConvert+BDMapKit.m
//  RNIbuildModuleBaiduMap
//
//  Created by Wentao Ye on 19/05/2017.
//  Copyright © 2017 Facebook. All rights reserved.
//

#import "RCTConvert+BDMapKit.h"

@implementation RCTConvert(BDMapKit)

+ (BDMapAnnotation *)BDMapAnnotation:(id)json
{
    json = [self NSDictionary:json];
    BDMapAnnotation* annotation = [[BDMapAnnotation alloc]init];
    annotation.areaCode = (json[@"areaCode"] != [NSNull null] ? [self NSString:json[@"areaCode"]] : @"");
    annotation.areaName = (json[@"areaName"] != [NSNull null] ? [self NSString:json[@"areaName"]] : @"");
    annotation.areaType = [self NSInteger:json[@"areaType"]];
    annotation.projectCount = [self NSInteger:json[@"projectCount"]];
    annotation.projectCode = (json[@"projectCode"] != [NSNull null] ? [self NSString:json[@"projectCode"]] : @"");
    annotation.projectName = (json[@"projectName"] != [NSNull null] ? [self NSString:json[@"projectName"]] : @"");
    annotation.projectLevel = [self NSInteger:json[@"projectLevel"]];
    
    CLLocationCoordinate2D coor;
    coor.latitude = [self float:json[@"locationY"]];
    coor.longitude = [self float:json[@"locationX"]];
    annotation.coordinate = coor;
    return annotation;
}

+ (MapStatusInfo *)MapStatusInfo:(id)json
{
    json = [self NSDictionary:json];
    MapStatusInfo* info = [[MapStatusInfo alloc]init];
    info.locationY = [self NSNumber:json[@"locationY"]];
    info.locationX = [self NSNumber:json[@"locationX"]];
    info.zoomLevel = [self NSNumber:json[@"zoomLevel"]];
    return info;
}

RCT_ARRAY_CONVERTER(BDMapAnnotation)

@end
